﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Text;
using ReflectionStudio.Core.Events;
using INTEX.DataBase.Tools;
namespace WPFExcelReport
{

    public class JLTQC20Data : BaseFunction
    {
        
        public JLTQC20Data()
            : base()
        {

        }
        public JLTQC20Data(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        }

        public DataSet GetQC20(DataRow dwABPOS)
        {
            DataSet Result;
            DataSet Return = new DataSet();
            string TableName = "QC20";
            string ART = dwABPOS["ART"].ToString().Trim();
            string FROMDNDATE = dwABPOS["FROMDNDATE"].ToString().Trim();
            string ENDDNDATE = dwABPOS["ENDDNDATE"].ToString().Trim();
            try
            {
                #region
                /*SELECT DISTINCT to_number(A.QOKORDER) as qcorder,A.QOKNEUD,A.QOKERLDAT, "
                    + " A.QOKRESULT AS RESULT,A.QOKKUNDPART AS TYPE, "
                    + " TRIM(QOKPNRKRS)||'-'||TO_NUMBER(QOKPLFDNR) AS QPLAN,  "
                    + " A.QOKWEPARTIE,A.QOKARTST,TRIM(A.QOKART)AS ART,TRIM(A.QOKFARBE) AS COLOR,  "
                    + " A.QOKBESCHICH,QOKAUFTYP,TRIM(QOKAUFKRS)||'-'||TO_NUMBER(A.QOKAUFLFD)  "
                    + " ||'-'||TO_NUMBER(QOKAUFPOS)||'-'||TO_NUMBER(QOKTP) AS ORDERNO,A.QOKFRBENID,  "
                    + " TO_NUMBER(A.QOKPKUNDNR) AS CUSTOMER,A.QOKVKAUFTYP, "
                    + " TRIM(A.QOKVKAUFKRS)||'-'||TO_NUMBER(A.QOKVKAUFLFD)||'-'||TO_NUMBER(A.QOKVKAUFPOS) AS SO, "
                    + " (select substr(sddaten,52,10)from sddat where sdsa = '0734' and substr(sddaten,1,1)='A'   "
                    + " and substr(sdkey,3,1) = E.VAAALTERNAT ) as STRNAME,  "
                    + " (select substr(sddaten,2,20)  from sddat where sdsa = '0178' and substr(sdkey,24,1)='V'   "
                    + "  and substr(sddaten,1,1)='A' and substr(sdkey,3,3) = VAAARTGRP ) as ARTNAME,  "
                    + "  nvl(F.yarn,E.VAABEZ) AS DESCR, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '01'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A01, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))   "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '02'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A02, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))   "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '03'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A03, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))   "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '04'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A04,"
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))   "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '05'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A05, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))   "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '06'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A06, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))   "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '07'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A07, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001)) "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  " 
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '08'  "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A08, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '09'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A09, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '10'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A10, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '11'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A11, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '12'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A12, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '13'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A13, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  " 
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '14'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A14, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '15'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A15, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '16'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A16, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '17'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A17, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '18'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A18, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '19'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A19, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '20'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A20, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '21'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A21, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '22'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A22, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '23'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A23, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '24'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A24, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '25'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A25, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '26'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A26, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '27'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A27, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '28'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A28, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '29'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A29, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '30'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A30, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '31'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A31, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '32'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A32, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '33'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A33, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '34'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A34, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '35'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A35, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '36'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A36, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '37'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A37, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '38'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A38, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '39'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A39, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '40'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A40, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '41'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A41, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '42'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A42, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '43'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A43, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '44'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A44, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '45'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A45, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '46'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A46, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '47'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A47, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '48'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A48, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '49'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A49, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '50'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A50, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '51'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A51, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '52'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A52, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '53'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A53, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '54'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A54, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '55'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A55, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '56'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A56, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '57'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A57, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '58'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A58, "
                    + " (select max(decode(B.QOEANZIW,0, ' ',B.QOEMWERT*0.001))  "
                    + " from qostep b,QPMERKM c where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '59'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER) AS A59 "
                    + " FROM QORDER A,VAART E,  "
                    + " (select TRIM(T1.TXTISIND) AS ART,TRIM(T2.TXTKTEXT) AS YARN   "
                    + " from txtind T1,TXTKON T2 where T1.txtitxtart = 'VAD'  "
                    + " AND T1.TXTIMANDANT = T2.TXTKMANDANT AND T1.TXTIPIND = T2.TXTKPIND) F  "
                    + " WHERE A.QOKART = E.VAADART AND E.vaakoll||trim(E.vaaart) = F.art(+)  "
                    + " AND (A.QOKNEUD >= " + FROMDNDATE + " AND  A.QOKNEUD <= " + ENDDNDATE + ") "
                    + " AND A.QOKART LIKE '" + ART + "%' "
                    + " ORDER BY 1,2 "*/
                #endregion
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT DISTINCT to_number(A.QOKORDER) as qcorder,A.QOKNEUD,A.QOKERLDAT, "
                    + " trim(Q.QOSIDENT) as QOSIDENT,QOSPRODDATE,A.QOKRESULT AS RESULT,A.QOKKUNDPART AS TYPE, "
                    + " TRIM(QOKPNRKRS)||'-'||TO_NUMBER(QOKPLFDNR) AS QPLAN, "
                    + " A.QOKWEPARTIE,A.QOKARTST,TRIM(A.QOKART)AS ART,TRIM(A.QOKFARBE) AS COLOR, "
                    + " A.QOKBESCHICH,QOKAUFTYP,TRIM(QOKAUFKRS)||'-'||TO_NUMBER(A.QOKAUFLFD) "
                    + " ||'-'||TO_NUMBER(QOKAUFPOS)||'-'||TO_NUMBER(QOKTP) AS ORDERNO,A.QOKFRBENID, "
                    + " TO_NUMBER(A.QOKPKUNDNR) AS CUSTOMER,A.QOKVKAUFTYP, "
                    + " TRIM(A.QOKVKAUFKRS)||'-'||TO_NUMBER(A.QOKVKAUFLFD)||'-'||TO_NUMBER(A.QOKVKAUFPOS) AS SO,"
                    + " (select substr(sddaten,52,10)from sddat where sdsa = '0734' and substr(sddaten,1,1)='A'  "
                    + " and substr(sdkey,3,1) = E.VAAALTERNAT ) as STRNAME, "
                    + " (select substr(sddaten,2,20)  from sddat where sdsa = '0178' and substr(sdkey,24,1)='V'  "
                    + "  and substr(sddaten,1,1)='A' and substr(sdkey,3,3) = VAAARTGRP ) as ARTNAME, "
                    + "  nvl(F.yarn,E.VAABEZ) AS DESCR, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(to_char(H.QOVNIWERT*0.001,'99990.99'),'99990.99'))) "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '01'  "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR) AS A01, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(to_char(H.QOVNIWERT*0.001,'99990.99'),'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H "
                    + " where b.qoemandant = c.qpmmandant "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '02'  "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR) AS A02, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(to_char(H.QOVNIWERT*0.001,'99990.99'),'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '03'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR) AS A03, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(to_char(H.QOVNIWERT*0.001,'99990.99'),'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '04'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A04, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '05'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A05, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '06'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A06, "
                    + "  (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant  "
                    + " AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '07'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A07, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + "  where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '08'  "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A08, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '09'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A09, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '10'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A10, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '11'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A11, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '12'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A12, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '13'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A13, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '14'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A14, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '15'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A15, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '16'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A16, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '17'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A17, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '18'  "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A18, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '19'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A19, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '20'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A20, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '21'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A21, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '22'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A22, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '23'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A23, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '24'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A24, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '25'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A25, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '26'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A26, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '27'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A27, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '28'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A28, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '29'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A29, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '30'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A30, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '31'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A31, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '32'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER  "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A32, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '33'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A33, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '34'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A34, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99'))) "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '35'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A35, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '36'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A36, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '37'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A37, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '38'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A38, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '39'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A39, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '40'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A40, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '41'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A41, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '42'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER  "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A42, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '43'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A43, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '44'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A44, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '45'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A45, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '46'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A46, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '47'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A47, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '48'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A48, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '49'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A49, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '50'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A50, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '51'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A51, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '52'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A52, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H   "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '53'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A53, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '54'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A54, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '55'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A55, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '56'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A56, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '57'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A57, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '58'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A58, "
                    + " (select MAX(decode(H.QOVNIWERT,0,H.QOVAIWERT,to_char(H.QOVNIWERT*0.001,'99990.99')))  "
                    + " from qostep b,QPMERKM c,QSAMPLE S,QOVALUE H  "
                    + " where b.qoemandant = c.qpmmandant AND B.QOEMERKM = C.QPMMERKM AND C.QPMVARDBL1 = '59'   "
                    + " AND B.QOEMANDANT = A.QOKMANDANT AND B.QOEORDER = A.QOKORDER "
                    + " AND B.QOEMANDANT = S.QOSMANDANT AND B.QOEORDER = S.QOSORDER "
                    + " AND B.QOEMANDANT = H.QOVMANDANT AND B.QOEORDER = H.QOVORDER "
                    + " AND B.QOESTEP = H.QOVSTEP AND S.QOSPNR = H.QOVPNR AND S.QOSPNR = Q.QOSPNR ) AS A59 "
                    + " FROM QORDER A,VAART E, QSAMPLE Q, "
                    + " (select TRIM(T1.TXTISIND) AS ART,TRIM(T2.TXTKTEXT) AS YARN   "
                    + " from txtind T1,TXTKON T2 where T1.txtitxtart = 'VAD'  "
                    + " AND T1.TXTIMANDANT = T2.TXTKMANDANT AND T1.TXTIPIND = T2.TXTKPIND) F  "
                    + " WHERE A.QOKART = E.VAADART AND E.vaakoll||trim(E.vaaart) = F.art(+)  "
                    + " AND A.QOKMANDANT = Q.QOSMANDANT AND A.QOKORDER = Q.QOSORDER "
                    + " AND (A.QOKNEUD >= " + FROMDNDATE + " AND  A.QOKNEUD <= " + ENDDNDATE + ") "
                    + " AND A.QOKART LIKE '" + ART + "%' "
                    + " ORDER BY 1,2 "
                    ;

                Result = Connect2Proxy(orlReadCommand);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = TableName;
                    byte[] b;
                    string value;
                    foreach (DataRow dw in Result.Tables[TableName].Rows)
                    {
                        foreach (DataColumn cm in Result.Tables[TableName].Columns)
                        {
                            string cn = cm.ColumnName;
                            b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[cn].ToString().Trim());
                            value = Encoding.GetEncoding("gb2312").GetString(b);
                            dw[cn] = value;
                        
                        }
                        /*
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["TYPE"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["TYPE"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["STRNAME"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["STRNAME"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["ARTNAME"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["ARTNAME"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["DESCR"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["DESCR"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["QOSIDENT"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["QOSIDENT"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["A05"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["A05"] = value;
                         * */
                    }
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet GetTYPE(DataRow dwABPOS)
        {
            DataSet Result;
            DataSet Return = new DataSet();
            string TableName = "TYPE";
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT SUBSTR(SDKEY,3,2) AS CODE, TRIM(SUBSTR(SDDATEN,2,30)) AS DES "
                    + " FROM SDDAT WHERE SDSA= '9901'  ";

                Result = Connect2Proxy(orlReadCommand);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = TableName;
                    byte[] b;
                    string value;
                    foreach (DataRow dw in Result.Tables[TableName].Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["DES"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["DES"] = value;
                    }
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }       
        public DataSet BuildJLTQC20Data(DataRow dwUI)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            try
            {
                setResult = GetTYPE(dwUI);
                setReturn.Merge(setResult);
                setResult = GetQC20(dwUI);
                setReturn.Merge(setResult);  
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
    }
}